export function useOpPerms(op) {
  // 索引越大权限越大
  const perms = ['查看', '标注', '审核'];
  const level = R.indexOf(op, perms);

  /** 进入标注界面的操作是否 __（等于/大于）指定操作 */
  const Comparator = f => s => R.apply(f, [level, R.indexOf(s, perms)]);
  const OpEq = Comparator(R.equals);
  const OpGte = Comparator(R.gte);

  /** 小于等于权限等级的函数都调用 */
  function addPerms(dic) {
    return () => R.compose(
      R.forEach(R.call),
      R.unnest,
      R.slice(0, level),
      R.values,
    )(dic);
  }

  return {
    OpEq,
    OpGte,
    addPerms,
  };
}
